package com.ruoyi.eam.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.eam.doman.EamAsset;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.eam.doman.EamStockD;
import com.ruoyi.eam.service.IEamStockDService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 入库从Controller
 * 
 * @author ruoyi
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/stockD")
public class EamStockDController extends BaseController
{
    @Autowired
    private IEamStockDService eamStockDService;

    /**
     * 查询入库从列表
     */
//    @RequiresPermissions("system:d:list")
    @GetMapping("/list")
    public TableDataInfo list(EamStockD eamStockD)
    {
        startPage();
        List<EamStockD> list = eamStockDService.selectEamStockDList(eamStockD);
        return getDataTable(list);
    }

    /**
     * 导出入库从列表
     */
    //@RequiresPermissions("system:d:export")
    @Log(title = "入库从", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EamStockD eamStockD)
    {
        List<EamStockD> list = eamStockDService.selectEamStockDList(eamStockD);
        ExcelUtil<EamStockD> util = new ExcelUtil<EamStockD>(EamStockD.class);
        util.exportExcel(response, list, "入库从数据");
    }

    /**
     * 获取入库从详细信息
     */
    //@RequiresPermissions("system:d:query")
    @GetMapping(value = "/{stokId}")
    public AjaxResult getInfo(@PathVariable("stokId") Long stokId)
    {
        return success(eamStockDService.selectEamStockDByStokId(stokId));
    }

    /**
     * 新增入库从
     */
    //@RequiresPermissions("system:d:add")
    @Log(title = "入库从", businessType = BusinessType.INSERT)
    @PostMapping("/addD")
    public AjaxResult addD(@RequestBody List<EamAsset> eamAssets)
    {
        return toAjax(eamStockDService.insertEamStockD(eamAssets));
    }


    /**
     * 修改入库从
     */
    //@RequiresPermissions("system:d:edit")
    @Log(title = "入库从", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EamStockD eamStockD)
    {
        return toAjax(eamStockDService.updateEamStockD(eamStockD));
    }

    /**
     * 删除入库从
     */
    //@RequiresPermissions("system:d:remove")
    @Log(title = "入库从", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stokIds}")
    public AjaxResult remove(@PathVariable Long[] stokIds)
    {
        return toAjax(eamStockDService.deleteEamStockDByStokIds(stokIds));
    }
}
